/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import javax.ejb.Stateless;
import entities.Event;
import entities.EventType;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import persistance.dao.SignumDAO;
import persistance.model.*;

/**
 *
 * @author Bobok
 */
@Singleton
public class FromSignumEventTypeDAO implements EventTypeDAOLocal {
    @EJB
    private SignumDAO signumDAO;

    public List<EventType> getAll() {
        List<Signum> markers = signumDAO.getAll();
        List<EventType> eventTypes = new ArrayList<EventType>();
        for (Signum signum : markers) {
            eventTypes.add(this.toEventType(signum));
        }
        return eventTypes;
    }

    public EventType getDefault() {
        return toEventType(signumDAO.getDefault());
    }

    public EventType getByName(String name) {
        return toEventType(signumDAO.getByName(name));
    }

    private EventType toEventType(Signum signum){
        return new EventType(signum.getName(), signum.getIconUrl());
    }

    private Signum toSignum(EventType eventType){
        Signum signum = new Signum();
        signum.setName(eventType.getName());
        signum.setIconUrl(eventType.getIconUrl());
        return signum;
    }
}
